﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management.Automation;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Collections;


namespace BELT
{
    [Cmdlet("Set", "BrowserElement")]
    public class SetBrowserElementCommand : Cmdlet
    {
        private Object _targetObject;
        private string _value;
        [Parameter(Mandatory = true, ValueFromPipeline = true)]
        public Object TargetObject
        {
            get
            {
                return _targetObject;
            }
            set
            {
                PSObject psObj = (PSObject)value;
                _targetObject = psObj.BaseObject;
            }
        }
        [Parameter(Mandatory = true, ValueFromPipeline = false, Position = 0)]
        public string Value {
            get {
                return _value;
            }
            set {
                _value = value;
            }
        }
        protected override void BeginProcessing()
        {
            base.BeginProcessing();
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            Type objType = _targetObject.GetType();
            objType.InvokeMember("value", BindingFlags.SetProperty, null, _targetObject, new object[1] { _value });
        }
        protected override void EndProcessing()
        {
            base.EndProcessing();
        }
    }
}
